package com.soryin.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * Json获取数据
 * @author Hello_海生
 * @date 2014年4月17日
 */
public class HttpUtil {

	
	//Json 代理
	public static JSONObject getJsonp(String url){
		JSONObject jsonObj= JSON.parseObject(getContent(url));
		return jsonObj;
	}
	
	
	
	//读取网络内容
	public static String getContent(String strUrl) {  
        try {  
            URL url = new URL(strUrl);  
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));  
            String s = "";  
            StringBuffer sb = new StringBuffer("");  
            while ((s = br.readLine()) != null){
            	sb.append(s);  
            }
            br.close();  
            return sb.toString();  
        } catch (Exception e) {  
            return "error open url:" + strUrl;  
        }  
  
    }
}
